﻿using HRMSystemShi.DAL;

namespace HRMSystemShi._2025
{
    public partial class FormOperator : Form
    {
        public FormOperator()
        {
            InitializeComponent();

            dataGridViewOperator.DataSource = OperatorService.GetOperatorList();
            dataGridViewOperator.ReadOnly = true;
        }

        private void buttonFIxed_Click(object sender, EventArgs e)
        {
            if (dataGridViewOperator.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择要修改的行", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                Guid id = (Guid)dataGridViewOperator.SelectedRows[0].Cells["Id"].Value;
                FormOperatorEdit formOperatorEdit = new FormOperatorEdit(id);
                formOperatorEdit.ShowDialog();
                dataGridViewOperator.DataSource = OperatorService.GetOperatorList();
            }
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            FormOperatorEdit formOperatorEdit = new FormOperatorEdit();
            formOperatorEdit.ShowDialog();
        }
    }
}
